﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CommonShop.Service;

using NHibernate;
using CommonShop.Service.Helper;

namespace CommonShop.Web.Areas.Manage.Controllers
{
    public class ProductController : Controller
    {
        ISessionFactory serviceFactory = null;
        public ProductController()
        {
            serviceFactory = FluentSessionFactory.GetCurrentFactory();
        }

        //
        // GET: /Manage/Product/

        public ActionResult Index()
        {
            using (var session = serviceFactory.OpenSession())
            {
                IList<Product> productList = session.CreateQuery("from Product").List<Product>();
                return View(productList.ToList());
            }

        }

        public ActionResult AddProduct()
        {
            return View();
        }

        [HttpPost]
        public ActionResult AddProduct(Product product)
        {
            if (ModelState.IsValid)
            {
                using (var session = serviceFactory.OpenSession())
                {

                }

            }
            return View();
        }
    }
}
